﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using XmlSockets;

namespace XmlSocketClientTest
{
    class XmlSocketClientTest
    {
        static void Main(string[] args)
        {
            var clientXmlSocket = new ClientXmlSocket();

            clientXmlSocket.Received += (m) =>
            {
                foreach(var message in m.Messages)
                {
                    Console.WriteLine("message=" + message.ToString());
                }

                
            };

            
            var addr = "omsg104.live.nicovideo.jp";


            var port = 2811;

            clientXmlSocket.ConnectAsync(addr, port).GetAwaiter().GetResult();
            var requestMessage = new XElement("thread");
            requestMessage.SetAttributeValue("thread", "1030258764");
            requestMessage.SetAttributeValue("res_from", "-200");
            requestMessage.SetAttributeValue("version", "20061206");
            requestMessage.SetAttributeValue("scores", "1");
            clientXmlSocket.SendAsync(requestMessage).GetAwaiter().GetResult();
            Console.WriteLine("receiveStart");
            Console.ReadLine();
        }
    }
}
